package com.medishare.adapter;

import com.medishare.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SpeeddialAdapter extends BaseAdapter{
	private Context context;
	private ViewHolder holder;
	private Integer[] imgIntegers = {
			R.drawable.fragment_medi_reminder_title,
			R.drawable.icon_doctor_notice,
			R.drawable.icon_vaccine_notice,
			R.drawable.icon_follow_up_record,
			R.drawable.icon_book_medicine,
			R.drawable.icon_call_assistant,
			R.drawable.icon_book_doctor,
			R.drawable.icon_health_known,
			R.drawable.icon_health_test,
			R.drawable.icon_community_activity,
			R.drawable.icon_weather_info,
			R.drawable.icon_health_tip,
	};
	private Integer[] titleIntegers = {
			R.string.drug_notice,
			R.string.appt_notice,
			R.string.vaccine_notice,
			R.string.visit_record,
			R.string.appt_drug,
			R.string.call_helper,
			R.string.make_appt,
			R.string.health_knowl,
			R.string.health_test,
			R.string.event_notice,
			R.string.weather_notice,
			R.string.health_tips
	};
	
	public SpeeddialAdapter(Context context) {
		// TODO Auto-generated constructor stub
		this.context = context;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if (imgIntegers != null) {
			return imgIntegers.length;
		}else {
			return 0;
		}
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View view, ViewGroup viewGroup) {
		// TODO Auto-generated method stub
		if (view == null){
			holder = new ViewHolder();
			LayoutInflater inflater = LayoutInflater.from(context);
			view = inflater.inflate(R.layout.speeddial, null);
			view.setTag(holder);
			view.setPadding(15, 15, 15, 15);
		}else {
			holder = (ViewHolder) view.getTag();
		}
		
		holder.img = (ImageView) view.findViewById(R.id.img);
		holder.img.setBackgroundResource(imgIntegers[position]);
		holder.title = (TextView) view.findViewById(R.id.text);
		holder.title.setText(titleIntegers[position]);
		
		return view;
	}
	
	static class ViewHolder{
		public ImageView img;
		public TextView title;
	}
}
